<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title> New Document </title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <link rel="stylesheet" href="/common/js/datepicker/css/smoothness/jquery-ui-1.9.2.custom.min.css"/>
 
<script type="text/javascript" src="/common/js/jquery-1.11.0.js"></script>
<script type="text/javascript" src="/common/js/common.js"></script>
<script type="text/javascript" src="/common/js/serviceCall.js"></script>
<script type="text/javascript" src="/common/js/datepicker/jquery-ui-1.9.2.custom.js"></script>
<script type="text/javascript" src="/common/js/datepicker/datepicker.config.js"></script>
<script type="text/javascript" src="/common/js/date.js"></script>
<script type="text/javascript" src="/common/js/json.js"></script>
<?include_once $_SERVER['DOCUMENT_ROOT'].'/common/util/commonViewInclude.php'?>
<script type="text/javascript">
var param = {}; 

var test = new NormalServiceCaller("SVC0004");
var listCnt = 0;
var paging = null;

function fn_searchData(){
	var param = $("form").serialize();
	
	test.searchSvc(function(data){
		/*페이징 세팅*/
		
		if(listCnt!=data.cnt){
			listCnt = data.cnt;
			paging = new PagingNaviFactory("pagingNaviArea",{totalRowCount : data.cnt }, function(){
				fn_searchData();
			});
			paging.initPageNavi();
			
			
		}
		/*페이징 세팅*/
		GFN_PAGENAVIGATION_VARS.pageStartNum = paging.getPageStartNum();
		var $table = $("<table>").attr("border","1");
		var $tbody = $("#table tbody").empty();
		$.each(data.data, function(k, v){
			var $tr = $("<tr>");
			$tr.append(
				$("<td>").text(GFN_PAGENAVIGATION_VARS.pageStartNum--)
			).append(
				$("<td>").text(v.regdate)
			).append(
				$("<td>").text(v.roomType)
			).append(
				$("<td>").append($("<a>").text(v.name).attr({href:'view.php?idx='+v.idx	}))
			);
			$tbody.append($tr);		
		});
		 
		//$("#table").html($table);
	}, param);	
}

$(function(){
	fn_searchData();	
	fn_datepicker("#sdate","#edate");
	$("#search").click(function(){
		//$("#pageIndex").val(1);
		paging.goPage(1);
		fn_searchData();	
		//asdf("#formid");
	});

	$(".searchDate").click(function(){
		var dDay = parseInt($(this).attr("dDay"));
		
		$("#sdate").val(Date.today().add(dDay).day().format("yyyy-MM-dd"));
		$("#edate").val(Date.today().format("yyyy-MM-dd"));
	});
});

function asdf(formId){
	var input = $(formId).find("input[type=text], input[type=checkbox], input[type=radio], input[type=select]");
	$.each(input, function(k, v){
		console.log(v)
	});
	
}

</script> 
</HEAD>
 <BODY>
  	<form id="formid">
  	<input type="hidden" name="pageIndex" id="pageIndex" value="1"/>
  	<div id="ddd"></div>
  	<div>
  		
  	</div>
  	<div>
  		<table border=1>
  		<tr>
  			<td>검색기간</td>
  			<td>
  				<input type="input" name="sdate" id="sdate">  ~ 
  				<input type="input" name="edate" id="edate">
  			</td>
  			<td>
  				<input type="button" value="오늘" class="searchDate" dDay="0"/>
  				<input type="button" value="최근7일" class="searchDate" dDay="-7"/>
  				<input type="button" value="최근15일" class="searchDate" dDay="-15"/>
  				<input type="button" value="최근1개월" class="searchDate" dDay="-31"/>
  				<input type="button" value="최근3개월" class="searchDate" dDay="-93"/>
  			</td>
  		</tr>
  		<tr>
  			<td rowspan="3">검색옵션</td>
  			<td>예약번호</td>
  			<td><input type="text" name="c"/></td>
  			<td>예약자명</td>
  			<td><input type="text" name="name"/></td>
  		</tr>
  		<tr>
  			<td>전화번호</td>
  			<td><input type="text" name="e"/></td>
  			<td>객실명</td>
  			<td><input type="text" name="f"/></td>
  		</tr>
  		<tr>
  			<td>예약상태</td>
  			<td><input type="checkbox" name="g"/>입금대기</td>
  		</tr>
  		
  		</table>
  		
  		<div id="table">
  			<table border="1">
  			<thead>
  				<th>번호</th>
  				<th>예약일자</th>
  				<th>객실</th>
  				<th>예약자</th>
  			</thead>
  			<tbody>
  			</tbody>
  			</table>
  		</div>
  	</div>
  	<input type="button" id="search" value="조회"/>
  	<div id="pagingNaviArea"></div>
  	</form>
 </BODY>
</HTML>


